package dmir.wikipedia;


public class WikiLink {

    private int start;
    private int length;
    private String anchorTarget;
    private String anchorText;
    
    public int getStart() {
        return start;
    }

    public int getLength() {
        return length;
    }

    public String getAnchorTarget() {
        return anchorTarget;
    }

    public String getAnchorText() {
        return anchorText;
    }

    public void setStart(int start) {
        this.start = start;
    }

    public void setLength(int length) {
        this.length = length;
    }

    public void setAnchorTarget(String anchorTarget) {
        this.anchorTarget = WikiPage.encodeWikistyle( anchorTarget );
    }
    
    public void setAnchorText(String anchorText) {
        this.anchorText = anchorText;
    }
    
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder("[[");
        sb.append(anchorTarget);
        if (!anchorTarget.equals(anchorText)) {
          sb.append("|").append(anchorText);  
        } 
        sb.append("]]");     
        return sb.toString();
    }
}
